package com.ftg.learn.chapter08.pattern.singleton.thread;

/**
 * 优化
 *
 * @author lijiaxin
 * @version 1.0
 * @date 2023/8/2 18:02
 */

public class Thread03 {

    public static void main(String[] args) {

        //创建线程 匿名
        Runnable t1=new Runnable() {
            @Override
            public void run() {
                System.out.println("我是线程");
            }
        };

        //start();启动方法 准备状态
        //run();  执行状态


        new Thread(t1).start();

        //lambda表达式
        Runnable t2 = ()->{
            System.out.println("我是线程");
        };
        new Thread(t2).start();

        //就用哪一个
        Thread t3 = new Thread(()->{
            System.out.println("ttt");
        });


        t3.setName("线程名称");
        t3.start();

        Thread t4 = new Thread(()->{
            System.out.println("ttt"+Thread.currentThread().getName());
        },"哈尔滨");
        t4.start();

    }
}
